import roleApi from '@/api/declaration/roleApi'
import httpRequest from '@/config/axios/httpRequest'
import {
  CreateRoleReq,
  CreateRoleResp,
  DeleteRoleReq,
  DeleteRoleResp,
  ExportRoleReq,
  QueryRoleDetailReq,
  QueryRoleDetailResp,
  QueryRolePageReq,
  QueryRolePageResp,
  UpdateRoleReq,
  UpdateRoleResp
} from '@/models/system/RoleModel'

// 查询角色列表
export const getRolePage = async (params: QueryRolePageReq) => {
  return await httpRequest.get<QueryRolePageResp>(roleApi.QueryRolePage, { params })
}

// 查询角色详情
export const getRole = async (params: QueryRoleDetailReq) => {
  return await httpRequest.get<QueryRoleDetailResp>(roleApi.QueryRoleDetail, { params })
}

// 新增角色
export const createRole = async (data: CreateRoleReq) => {
  return await httpRequest.post<CreateRoleResp>(roleApi.CreateRole, data)
}

// 修改角色
export const updateRole = async (data: UpdateRoleReq) => {
  return await httpRequest.put(roleApi.UpdateRole, data)
}

// 修改角色状态
export const updateRoleStatus = async (data: UpdateRoleReq) => {
  return await httpRequest.put<UpdateRoleResp>(roleApi.UpdateRoleStatus, data)
}

// 删除角色
export const deleteRole = async (params: DeleteRoleReq) => {
  return await httpRequest.delete<DeleteRoleResp>(roleApi.DeleteRole, { params })
}

// 导出角色
export const exportRole = async (params: ExportRoleReq) => {
  return await httpRequest.download(roleApi.ExportRole, { params, responseType: 'blob' })
}
